<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	May 17, 2010
 ^
 + Project: 		WRecruit
 * File Name:	views/resume/tmpl/company_jobs.php
 ^ 
 * Description: template view for company jobs
 ^ 
 * History:		NONE
 ^ 
 */
 
 defined('_JEXEC') or die('Restricted access');

 global $mainframe;
 $document =& JFactory::getDocument();
 $document->addStyleSheet('components/com_wrecruit/css/'.$this->config['theme']);
$link = ("index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=company_jobs&cd=". $this->companyid."&Itemid=".$this->Itemid);

if (isset($this->userrole->rolefor)){
	if ($this->userrole->rolefor != ''){
		if ($this->userrole->rolefor == 2) // job seeker
			$allowed = true;
		else
			$allowed = false;
	}else{
		$allowed = true;
	}
}else $allowed = true; // user not logined
   
?>
<?php if ($this->config['offline'] == '1'){ ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	<?php echo $this->config['title']; ?></td></tr>
	<tr><td height="25"></td></tr>
	<tr><td class="wrecruitmsg">
		<?php echo $this->config['offline_text']; ?>
	</td></tr>
</table>	
<?php }else{ ?>

<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	
		<?php echo $this->config['title']; ?>
	</td>
	</tr>
	<tr><td height="23"></td></tr>
	<?php if ($this->config['cur_location'] == 1) {?>
	<tr><td height="0"></td></tr>
	<tr><td class="curloc">
		<?php echo JText::_('JS_CUR_LOC'); ?> : <?php if ($this->jobs[0]->companyname != '') $ptitle = $this->jobs[0]->companyname; $ptitle =  $ptitle.' '.JText::_('JS_JOBS');	echo $ptitle; ?>
	</td></tr>
	<?php } ?>
	<tr><td>
			<?php 
			if (sizeof($this->jobseekerlinks) != 0){
				echo '<div id="toplinks"><ul>';
				foreach($this->jobseekerlinks as $lnk)	{ ?>
					<span <?php if($lnk[2] == 1)echo 'class="first"'; elseif($lnk[2] == -1)echo 'class="last"';  ?>>
						<a href="<?php echo $lnk[0]; ?>"> <?php echo $lnk[1]; ?></a>
					</span>
				<?php }
				echo '<ul></div>';			
			} 
			?>
	</td></tr>	
	<?php if ($allowed == true) { ?>
		<tr><td height="3"></td></tr>
		<tr><td>
		<form action="<?php echo JRoute::_($link); ?>" method="post" name="adminForm">
		<?php
			require_once( 'job_filters.php' );
		?>	
		</form>
		</td></tr>
	<?php } ?>
	<tr><td height="3"></td></tr>
	<tr><td class="<?php echo $this->theme['heading']; ?>" align="center">
		<?php if ($this->jobs[0]->companyname != '') $ptitle = $this->jobs[0]->companyname; 
		$ptitle =  $ptitle.' '.JText::_('JS_JOBS');
		echo $ptitle; ?> 
	</td></tr>

	<tr><td height="3"></td></tr>
</table>

<?php
if ($allowed == true) { 
if (isset($this->jobs)) {
	if ($this->sortlinks['sortorder'] == 'ASC')
		$img = "components/com_wrecruit/images/sort0.png";
	else
		$img = "components/com_wrecruit/images/sort1.png";
?>

	<table cellpadding="0" cellspacing="0" border="0" width="100%" >
		<tr class="<?php echo $this->theme['sortlinks']; ?>">
			<td class="<?php echo $this->theme['sortlinks']; ?>"  valign="center" align="center">&nbsp;&nbsp;<strong><?php echo JText::_('JS_SORT_BY'); ?> : </strong> 
				&nbsp;&nbsp;&nbsp;<strong><a class="<?php echo $this->theme['sortlinks']; ?>" href="<?php echo $link?>&sortby=<?php echo $this->sortlinks['title']; ?>"><?php echo JText::_('JS_TITLE'); ?></a></strong><?php if ($this->sortlinks['sorton'] == 'title') { ?> <img src="<?php echo $img ?>"> <?php } ?>
				&nbsp;&nbsp;|&nbsp;&nbsp;<strong><a class="<?php echo $this->theme['sortlinks']; ?>" href="<?php echo JRoute::_($link.'&sortby='. $this->sortlinks['jobtype']); ?>"><?php echo JText::_('JS_JOBTYPE'); ?></a></strong><?php if ($this->sortlinks['sorton'] == 'jobtype') { ?> <img src="<?php echo $img ?>"> <?php } ?>
				&nbsp;&nbsp;|&nbsp;&nbsp;<strong><a class="<?php echo $this->theme['sortlinks']; ?>" href="<?php echo $link?>&sortby=<?php echo $this->sortlinks['jobstatus']; ?>"><?php echo JText::_('JS_JOBSTATUS'); ?></a></strong><?php if ($this->sortlinks['sorton'] == 'jobstatus') { ?> <img src="<?php echo $img ?>"> <?php } ?>
				&nbsp;&nbsp;|&nbsp;&nbsp;<strong><a class="<?php echo $this->theme['sortlinks']; ?>" href="<?php echo $link?>&sortby=<?php echo $this->sortlinks['company']; ?>"><?php echo JText::_('JS_COMPANY'); ?></a></strong><?php if ($this->sortlinks['sorton'] == 'company') { ?> <img src="<?php echo $img ?>"> <?php } ?>
				&nbsp;&nbsp;|&nbsp;&nbsp;<strong><a class="<?php echo $this->theme['sortlinks']; ?>" href="<?php echo $link?>&sortby=<?php echo $this->sortlinks['country']; ?>"><?php echo JText::_('JS_COUNTRY'); ?></a></strong><?php if ($this->sortlinks['sorton'] == 'country') { ?> <img src="<?php echo $img ?>"> <?php } ?>
				&nbsp;&nbsp;|&nbsp;&nbsp;<strong><a class="<?php echo $this->theme['sortlinks']; ?>" href="<?php echo $link?>&sortby=<?php echo $this->sortlinks['salaryrange']; ?>"><?php echo JText::_('JS_SALARY_RANGE'); ?></a></strong><?php if ($this->sortlinks['sorton'] == 'salaryrange') { ?> <img src="<?php echo $img ?>"> <?php } ?>
				&nbsp;&nbsp;|&nbsp;&nbsp;<strong><a class="<?php echo $this->theme['sortlinks']; ?>" href="<?php echo $link?>&sortby=<?php echo $this->sortlinks['created']; ?>"><?php echo JText::_('JS_DATEPOSTED'); ?></a></strong><?php if ($this->sortlinks['sorton'] == 'created') { ?> <img src="<?php echo $img ?>"> <?php } ?>
			</td>
		</tr><?php
		$tdclass = array($this->theme['odd'], $this->theme['even']);
		$days = $this->config['newdays'];
		$isnew = date("Y-m-d H:i:s", strtotime("-$days days"));
		//$tdclass = array("odd", "even");
		$isodd =1;
		$istr=1;
		if ( isset($this->jobs) ){
			foreach($this->jobs as $job)	{
			$isodd = 1 - $isodd; ?>
		<tr height="20" class="<?php echo $tdclass[$isodd]; ?>" > <td colspan="5">
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr><td height="3"></td></tr>
				<?php if($this->listjobconfig['lj_title'] == '1') { ?>
				<tr>
					<td class="maintext">&nbsp;<strong><?php echo JText::_('JS_TITLE'); ?>	</strong></td>
					<td class="maintext" colspan="3"><?php echo $job->title;
					if ($job->created > $isnew)
						echo "<font color='red'> ".JText::_('JS_NEW')." </font>";
					?></td>
				<?php } ?>
				<?php if($istr) echo'</tr><tr>';  $istr = 2; ?>
				<?php if($this->listjobconfig['lj_jobtype'] == '1') { $istr++; ?>
					<td class="maintext" width="20%">&nbsp;<strong><?php echo JText::_('JS_JOBTYPE'); ?>	</strong></td>
					<td class="maintext" width="30%"><?php echo $job->jobtype; ?></td>
				<?php	} ?>
				<?php if($istr == 4){ echo '</tr><tr>';   $istr = 2;} ?>
					<?php if($this->listjobconfig['lj_jobstatus'] == '1') { $istr++; ?>
					<td class="maintext" width="20%">&nbsp;<strong><?php echo JText::_('JS_JOBSTATUS'); ?>	</strong></td>
					<td class="maintext" width="30%"><?php echo $job->jobstatus; ?></td>
				<?php	} ?>

				<?php if($istr == 4){ echo '</tr><tr>';  $istr = 2;} ?>
					<?php if($this->listjobconfig['lj_company'] == '1') { $istr++; ?>
					<td class="maintext">&nbsp;<strong><?php echo JText::_('JS_COMPANY'); ?>	</strong></td>
					<td class="maintext">
						<?php $link = 'index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=view_company&vm=2&md='.$job->companyid.'&jobcat='.$job->jobcategory.'&Itemid='.$this->Itemid; ?>
						<a href="<?php echo $link?>"><strong><?php echo $job->companyname; ?></strong></a>
					</td>
					<?php	} ?>
				<?php if($istr == 4){ echo '</tr><tr>';  $istr = 2;} ?>
					<?php if($this->listjobconfig['lj_companysite'] == '1') { $istr++; ?>
					<td class="maintext">&nbsp;<strong><?php echo JText::_('JS_COMPANYURL'); ?>	</strong></td>
					<td class="maintext"><a class="jplnks" href='<?php echo $job->url; ?>' target='_blank'><?php echo $job->url; ?></a></td>
				<?php	} ?>
				<?php if($istr == 4){ echo '</tr><tr>';  $istr = 2;} ?>
				<?php	if($this->listjobconfig['lj_country'] == '1') {  $istr++; ?>
					<?php if($job->countryname != '') { ?>
						<td >&nbsp;<strong><?php echo JText::_('JS_COUNTRY'); ?>	</strong></td>
						<td ><?php echo $job->countryname; ?></td>
					<?php } ?>
				<?php	} ?>
				<?php if($istr == 4){ echo '</tr><tr>';  $istr = 2;} ?>
				<?php	if($this->listjobconfig['lj_state'] == '1') {  $istr++; ?>
					<?php if(!empty($job->statename)) { ?>
						<td >&nbsp;<strong><?php echo JText::_('JS_STATE'); ?>	</strong></td>
						<td ><?php echo $job->statename; ?></td>
					<?php }else{ ?>
						<td >&nbsp;<strong><?php echo JText::_('JS_STATE'); ?>	</strong></td>
						<td ><?php echo $job->state; ?></td>
					<?php } ?>
				<?php	} ?>
				<?php if($istr == 4){ echo '</tr><tr>';  $istr = 2;} ?>
				<?php	if($this->listjobconfig['lj_county'] == '1') {  $istr++; ?>
					<?php if(!empty($job->countyname)) { ?>
						<td >&nbsp;<strong><?php echo JText::_('JS_COUNTY'); ?>	</strong></td>
						<td ><?php echo $job->countyname; ?></td>
					<?php }else{ ?>
						<td >&nbsp;<strong><?php echo JText::_('JS_COUNTY'); ?>	</strong></td>
						<td ><?php echo $job->county; ?></td>
					<?php } ?>
				<?php	} ?>
				<?php if($istr == 4){ echo '</tr><tr>';  $istr = 2;} ?>
				<?php	if($this->listjobconfig['lj_city'] == '1') {  $istr++; ?>
					<?php if(!empty($job->cityname)) { ?>
						<td >&nbsp;<strong><?php echo JText::_('JS_CITY'); ?>	</strong></td>
						<td ><?php echo $job->cityname; ?></td>
					<?php }else{ ?>
						<td >&nbsp;<strong><?php echo JText::_('JS_CITY'); ?>	</strong></td>
						<td ><?php echo $job->city; ?></td>
					<?php } ?>
				<?php	} ?>
				<?php if($istr == 4){ echo '</tr><tr>';  $istr = 2;} ?>
					
				<?php	  if($this->listjobconfig['lj_salary'] == '1') { $istr++; ?>
					 <?php if ( $job->jobsalaryrange != '' ) { 
								if ($job->jobsalaryrange != 0){ ?>
									<td class="maintext">&nbsp;<strong><?php echo JText::_('JS_SALARY_RANGE'); ?>	</strong></td>
									<td class="maintext"><?php $salary = $this->config['currency'] . $job->rangestart . ' - ' . $this->config['currency'] . $job->rangeend . ' /month';
									echo $salary; ?></td>
							<?php 	} 
							} ?>
				<?php	} ?>
			<?php if($istr == 4){ echo '</tr><tr>';   $istr = 2;} ?>
					<?php if($this->listjobconfig['lj_created'] == '1') { $istr++; ?>
					<td class="maintext">&nbsp;<strong><?php echo JText::_('JS_DATEPOSTED'); ?>	</strong></td>
					<td class="maintext"><?php echo date($this->config['date_format'],strtotime($job->created)); ?></td>
					<?php	} ?>
					<?php if($istr == 4){ echo '</tr><tr>';  $istr = 2;} ?>

					<?php if($this->listjobconfig['lj_noofjobs'] == '1') { $istr++; ?>
					<?php if ($job->noofjobs != 0){ ?>
					<td class="maintext">&nbsp;<strong><?php echo JText::_('JS_NOOFJOBS'); ?>	</strong></td>
					<td class="maintext"><?php echo $job->noofjobs; ?></td>
					<?php	} ?>
					<?php } ?>
				<?php if($istr == 4) echo '</tr>'; else echo '<td></td></tr>'; ?>
				
				
				
				<tr>
					<td></td><td></td>
					<td class="maintext" align="right"> 
						<?php $link = 'index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=view_job&vj=6&oi='.$job->id.'&Itemid='.$this->Itemid; ?>
						<a href="<?php echo $link?>" class="pageLink"><strong><?php echo JText::_('JS_VIEW'); ?></strong></a>
					&nbsp;&nbsp;</td>
					<td class="maintext" align="left">&nbsp;&nbsp;
						<?php $link = 'index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=job_apply&aj=4&bi='.$job->id.'&Itemid='.$this->Itemid; ?>
						<a href="<?php echo $link?>" class="pageLink"><strong><?php echo JText::_('JS_APPLYNOW'); ?></strong></a>
					</td>
				
				</tr>
				<tr><td height="3"></td></tr>
			</table>	
		</td></tr>
		<tr> <td colspan="5" height="1">	</td></tr>
				<?php } 
				} ?>	
	</table>
	<form action="<?php echo JRoute::_('index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=company_jobs&cd='.$this->companyid.'&Itemid='.$this->Itemid); ?>" method="post">
	<table cellpadding="0" cellspacing="0" border="0" width="100%" >
    <tr>
        <td></td>
        <td >
            <?php
            echo $this->pagination->getPagesLinks();
            ?>
        </td>
    </tr>
    <tr>
        <td align="left">
            <?php echo JText::_('JS_DISPLAY_#'); ?>
            <?php
            echo $this->pagination->getLimitBox();
            ?>
        </td>
        <td align="right">
            <?php
            echo $this->pagination->getResultsCounter();
            ?>
        </td>
    </tr>
	</table>
	</form>	
<?php
}else{ // no result found in this category
	echo JText::_('JS_RESULT_NOT_FOUND');
}

} else{ // not allowed job posting
	//Update by Vireak on 09/08/2012
	//Add frame to this warning and some styling
	//---------------------
	echo '<div class="box-list"><div class="head-title"><h2>Oop!</h2></div>';
	echo '<span class="wr_info"><p>'.JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW').'</p>';
	echo '<p>This page is reserved for the authorized employers or recruiters only. </p></span>';
	echo '</div>';
	//---------------------
}
}//ol
?>
<div width="100%">
<?php 
if($this->config['fr_cr_txsh']) {
	echo 
	'<table width="100%" style="table-layout:fixed;">
		<tr><td height="15"></td></tr>
		<tr><td style="vertical-align:top;" align="center">'.$this->config['fr_cr_txa'].$this->config['fr_cr_txb'].'</td></tr>
	</table>';
}	
?>
</div>
